html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>上下移动删除项</title>
    <style>
        body {
            font-family: Arial, sans-serif;
        }

        ul {
            list-style-type: none;
            padding: 0;
        }

        li {
            margin-bottom: 10px;
        }

        button {
            margin-left: 10px;
        }
    </style>
</head>
<body>
    <ul id="item-list">
        <li>项目 1 <button class="move-up" onclick="moveUp(this)">上移</button> <button class="move-down" onclick="moveDown(this)">下移</button> <button class="delete" onclick="deleteItem(this)">删除</button></li>
        <li>项目 2 <button class="move-up" onclick="moveUp(this)">上移</button> <button class="move-down" onclick="moveDown(this)">下移</button> <button class="delete" onclick="deleteItem(this)">删除</button></li>
        <li>项目 3 <button class="move-up" onclick="moveUp(this)">上移</button> <button class="move-down" onclick="moveDown(this)">下移</button> <button class="delete" onclick="deleteItem(this)">删除</button></li>
    </ul>

    <script>
        function moveUp(button) {
            const listItem = button.parentNode;
            const previousItem = listItem.previousElementSibling;
            if (previousItem) {
                listItem.parentNode.insertBefore(listItem, previousItem);
            }
        }

        function moveDown(button) {
            const listItem = button.parentNode;
            const nextItem = listItem.nextElementSibling;
            if (nextItem) {
                listItem.parentNode.insertBefore(nextItem, listItem);
            }
        }

        function deleteItem(button) {
            const listItem = button.parentNode;
            listItem.parentNode.removeChild(listItem);
        }
    </script>
</body>
</html>
